var flag = false;
var currentTabId;
chrome.browserAction.onClicked.addListener(function(tab) {
    flag = true;
    currentTabId = tab.id;
    chrome.tabs.getSelected(null, function(tab) {
        sendMsg(tab.id);
    });
});

//如果需要点击图标才执行过滤,把这个方法屏蔽掉即可
chrome.webNavigation.onCompleted.addListener(function(tab) {
    sendMsg(tab.tabId);
});


function sendMsg(tabid) {
    chrome.tabs.sendMessage(tabid, { greeting: "start working" }, function(response) {});
}